{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sqlite3\n",
    "# 创建一个数据库，cve_process.db\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 创建一个表, 对应CVE类型\n",
    "# class CVE:\n",
    "#     def __init__(self, cve_id, mainline_commitId, stable_commitId, title, fixes_commitId, cve_url, all_match_text):\n",
    "#         self.cve_id = cve_id\n",
    "#         # 以下信息均来自社区，可能为空\n",
    "#         self.mainline_commitId = mainline_commitId\n",
    "#         self.stable_commitId = stable_commitId #5.10\n",
    "#         self.title = title\n",
    "#         self.fixes_commitId = fixes_commitId\n",
    "#         self.cve_url = cve_url\n",
    "#         self.all_match_text = all_match_text\n",
    "def delete_cve_table():\n",
    "    conn = sqlite3.connect('cve_process.db')\n",
    "    c = conn.cursor()\n",
    "    c.execute('''DROP TABLE cve''')\n",
    "    conn.commit()\n",
    "    conn.close()\n",
    "def create_cve_table():\n",
    "    conn = sqlite3.connect('cve_process.db')\n",
    "    c = conn.cursor()\n",
    "    c.execute('''CREATE TABLE if not exists cve\n",
    "                 (cve_id text PRIMARY KEY,\n",
    "                 mainline_commitId text,\n",
    "                 stable_commitId text,\n",
    "                 title text,\n",
    "                 fixes_commitId text,\n",
    "                 cve_url text,\n",
    "                 all_match_text text)''')\n",
    "    conn.commit()\n",
    "    conn.close()\n",
    "create_cve_table()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
